package com.itheima.model.vo;

//import com.github.pagehelper.PageInfo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class PageResult implements Serializable {
        private static final long serialVersionUID = -669931479772321077L;
//    private static final long serialVersionUID = 1L;
    public long counts = 0L;//总记录数
    public Integer pagesize;//页大小
    public long pages = 0L;//总页数
    public Integer page;//当前页码
    public List items = Collections.emptyList(); //列表
    public List totals = Collections.emptyList();
    public PageResult(Integer page, Integer pagesize,
                      Long counts, List list) {
        this.page = page;
        this.pagesize = pagesize;
        this.items = list;
        this.counts = counts;
        this.pages = counts % pagesize == 0 ? counts / pagesize : counts / pagesize + 1;
    }
    /*public PageResult(List object) {
        PageInfo pageInfo = new PageInfo(object);
        this.counts = pageInfo.getSize();
        this.pages = pageInfo.getPages();
        this.pagesize = pageInfo.getPageSize();
        this.page = pageInfo.getPageNum();
        this.items = pageInfo.getList();
    }*/


}